package com.niit.shopsys.stub;

import com.niit.shopsys.PricingSystem;

import java.util.HashMap;
import java.util.Map;

// 价格系统测试桩
public class PricingSystemStub implements PricingSystem {
    private double defaultPrice;
    private Map<String, Double> priceMap = new HashMap<>();

    public PricingSystemStub(double defaultPrice) {
        this.defaultPrice = defaultPrice;
    }

    public void setPrice(String productId, String customerTier, double price) {
        String key = productId + "_" + customerTier;
        priceMap.put(key, price);
    }

    @Override
    public double getPrice(String productId, String customerTier) {
        String key = productId + "_" + customerTier;
        return priceMap.getOrDefault(key, defaultPrice);
    }
}

